extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	name = "[普通]存钱罐"
	att.maxHp = 200
	price = 200
	info = "战斗开始后，每秒积蓄1金币，受到敌方的伤害会损失2点积蓄\n若携带者死亡，则存钱罐会损坏，玩家只能获得100金币\n玩家可在商店售卖该道具，以获得当前积蓄的金币\n当前积蓄：[color=#DC143C]200"
var text = "战斗开始后，每秒积蓄1金币，受到敌方的伤害会损失2点积蓄\n若携带者死亡，则存钱罐会损坏，玩家只能获得100金币\n玩家可在商店售卖该道具，以获得当前积蓄的金币\n当前积蓄：[color=#DC143C]%d"
func _connect():
	._connect()
	if masCha.team == 2:
		att.maxHpL = 0.3
		return
	if masCha.isSumm:return
	sys.main.connect("onBattleEnd",self,"end")
	masCha.connect("onHurt",self,"onHurt")
	masCha.connect("onDeath", self, "onDeath")
	info = text%price

func _upS():
	if masCha == null || not utils.inBattle(masCha):return
	price += 1

func end():
	if masCha == null || not utils.inBattle(masCha):return
	info = text%price

func onHurt(atkInfo):
	if atkInfo.hitCha.team != atkInfo.atkCha.team:
		price -= 2

func onDeath(atkInfo):
	if masCha.isDeath:
		sys.newBaseMsg("哦豁", "存钱罐被打碎了！")
		sys.main.player.plusGold(100)
		delSelf()